#include <stdio.h>
#include <stdlib.h>
#include "common.h"
#include <time.h>


void press_any_key(void)
{
        printf("\n请按任意键返回...\n");
        // 关闭终端行缓冲和回显功能
        system("stty -icanon -echo");
        getchar();
        // 恢复终端行缓冲和回显功能
        system("stty icanon echo");
}


void print_member_info(const member_info* mi)
{
        printf("卡号：%s\n", mi->card_num);
        printf("会员ID：%u\n", mi->mid);
        printf("姓名：%s\n", mi->name);
        printf("性别：%s\n", mi->s == female ? "女" : "男");
        printf("手机号：%s\n", mi->phone);

        printf("会员类型：");
        if(mi->mt == cika)
        {
                printf("次卡\n剩余次数：%d\n", mi->remain_cnt);
        }
        else if(mi->mt == yueka)
        {
                printf("月卡\n");
        }
        else if(mi->mt == nianka)
        {
                printf("年卡\n");
        }

        struct tm* dt;

        dt = localtime(&mi->expire_time);

        printf("到期时间：%d年%d月%d日 %02d:%02d\n", dt->tm_year + 1900, dt->tm_mon + 1, dt->tm_mday, dt->tm_hour, dt->tm_min);

        dt = localtime(&mi->reg_time);

        printf("注册时间：%d年%d月%d日 %02d:%02d\n", dt->tm_year + 1900, dt->tm_mon + 1, dt->tm_mday, dt->tm_hour, dt->tm_min);
}

int my_atoi(const char* s)
{
	int i = 0, result = 0, sign = 1;
	while(s[i] == ' ' || s[i] == '\t' ||s[i] == '\n')
		i++;
	if(s[i] == '+') i++;
	else if(s[i] == '-')
	{
		sign = -1;
	}
	while(s[i] != '\0')
	{
		if(s[i] < '0' || s[i] > '9')
			break;
		result = result*10 + s[i] -'0';
	}
	return result * sign;
}
